package com.smart.stock.module;

public enum GlobalEnums {
    shapeOfHammer("shapeOfHammer", "锤子线"),
    shapeOfHangOneself("shapeOfHangOneself", "上吊线"),
    shapeOfStabUp("shapeOfStabUp", "刺透：向上"),
    shapeOfStabDown("shapeOfStabDown", "刺透：向下（乌云盖顶）"),
    shapeOfSwallowUp("shapeOfSwallowUp", "上涨吞没形态"),
    shapeOfSwallowDown("shapeOfSwallowDown", "下跌吞没形态")
    ;

    private String code;
    private String name;
    GlobalEnums(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static String getNameByCode(String code) {
        for (GlobalEnums x : GlobalEnums.values()) {
            if (x.getCode().equals(code)) {
                return x.getName();
            }
        }
        return null;
    }

    public static GlobalEnums getEnumsByCode(String code) {
        for (GlobalEnums x : GlobalEnums.values()) {
            if (x.getCode().equals(code)) {
                return x;
            }
        }
        return null;
    }


    public static String toJson() {
        String s = "";
        for (GlobalEnums x : GlobalEnums.values()) {
//            {"1":"hello"}
            s+=",{\""+x.getCode()+"\": \""+x.getName()+"\"}";
        }
        String res ="["+s.replaceFirst(",","")+"]";
        return res;
    }

}
